package com.example.college;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.NameValuePair;
import org.json.JSONObject;
import org.w3c.dom.Text;



import android.os.AsyncTask;
import android.os.Bundle;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Doctor extends Activity{

	JSONParser jParser = new JSONParser();
	
	Button button1;
	Button button2;
	
	
	
	
	
	
	private ProgressDialog pDialog;
	
	// url to get doctor's information
		private static String url_get_information = "http://192.168.140.1:8080/WebApplication2/webresources/doctor/";
		
		TextView doctorName;
		TextView doctorcourse;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.doctor_activity);
		
		
		doctorName = (TextView) findViewById(R.id.doctor_name);
		doctorName.setText(getIntent().getExtras().getString("id"));
		
		doctorcourse=(TextView) findViewById(R.id.doctor_course_name);
		
		
		new DoctorInfo().execute();
		
		button1=(Button) findViewById(R.id.edit_lec);
		button1.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// go to edit Lectures for doctors activity
				Intent	intent=new Intent(getApplicationContext(),EditLecturesForDoctors.class);
	             startActivity(intent);
				
			}
		});
		
		
		
		button2=(Button) findViewById(R.id.add_grades);
		button2.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// go to grades activtiy
				
				Intent	intent=new Intent(getApplicationContext(),Grades.class);
	             startActivity(intent);
				
			}
		});
		
	}
	
	/**
	 * Background Async Task to get doctor information
	 * */

class DoctorInfo extends AsyncTask<String, String, String>{
	/**
	 * Before starting background thread Show Progress Dialog
	 * */
	@Override
	protected void onPreExecute() {
		super.onPreExecute();
		pDialog=new ProgressDialog(Doctor.this);
		pDialog.setMessage("Getting information..");
		pDialog.setIndeterminate(false);
		pDialog.setCancelable(true);
		pDialog.show();
		
	}

	@Override
	protected String doInBackground(String... args) {
		// Building Parameters
	List<NameValuePair> params = new ArrayList<NameValuePair>();
		// getting JSON string from URL
			JSONObject json = jParser.makeHttpRequest(url_get_information, "GET", params);
				

					
					
					
					
		return null;
	}
	
	
	@Override
		protected void onPostExecute(String result) {
			pDialog.dismiss();
			
		}
	
	
	
	
	
	
}

	


}
